// pages/me/me.js
import {_t} from '../../i18n/base'
Page({
  data: {
    userInfo: {},
  },
  onClickLeft() {
    wx.navigateBack({
      delta: 0,
    })
  },
  initUserInfo() {
    let userInfo = wx.getStorageSync('userInfo')
    if (userInfo) {
      this.setData({
        userInfo: JSON.parse(userInfo),
      })
    } else {
      console.log('没登录')
      wx.switchTab({
        url: '/pages/index/index',
      })
    }
  },
  toSetting() {
    wx.navigateTo({
      url: '/pages/my/setting/setting',
    })
  },
  toCollect() {
    wx.navigateTo({
      url: '/pages/my/myCollect/myCollect',
    })
  },
  toFoot() {
    wx.navigateTo({
      url: `/pages/my/myFoot/myFoot`,
    })
  },
  toLang() {
    wx.navigateTo({
      url: '/pages/lang/lang',
    })
  },
  toInfo() {
    wx.navigateTo({
      url: '/pages/my/personalInfo/personalInfo',
    })
  },
  toPreference() {
    wx.navigateTo({
      url: '/pages/my/myPreference/myPreference',
    })
  },
  onShow() {
    this.initUserInfo()
  },
  onLoad(){
    let lang = _t();
    this.setData({
      lang
    })
    wx.setNavigationBarTitle({
      title: lang['个人中心'],
    })
  },
  handleContact(e) {
    console.log(e)
  },
})
